<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <title>后台信息管理系统</title>

    <link th:href="@{../../css/bootstrap.min.css}" rel="stylesheet" />
    <link th:href="@{../../font-awesome/css/font-awesome.css}" rel="stylesheet" />
    <link th:href="@{../../css/styleManage.css}" rel="stylesheet" />

    <link th:href="@{../../css/plugins/iCheck/custom.css}" rel="stylesheet"/>
    <link th:href="@{../../css/plugins/footable/footable.core.css}" rel="stylesheet"/>


    <!-- datetimepicker -->
    <link th:href="@{../../css/bootstrap-datetimepicker.css}" rel="stylesheet" media="screen"/>
    <link th:href="@{../../css/bootstrap-datetimepicker.min.css}" rel="stylesheet" media="screen"/>

</head>

<body>

<div id="wrapper">
    <nav class="navbar-default navbar-static-side" role="navigation" th:include="/manage/nav :: navigation"></nav>
    <div id="page-wrapper" class="gray-bg">
        <div class="border-bottom" th:include="/manage/header :: headerTop"></div>
        <div class="row wrapper border-bottom white-bg page-heading" th:fragment="headerNav">
            <div class="col-lg-10">
                <h2>订单管理</h2>
                <ol class="breadcrumb">
                    <li>
                        <a th:href="@{/manage/orderControl}">首页</a>
                    </li>
                    <li class="active">
                        <strong>订单管理</strong>
                    </li>
                </ol>
            </div>
            <div class="col-lg-2">
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>搜索&amp;操作</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content" style="display: block;">
                            <form action="/catalog/searchOrderList">
                                <div class="row">
                                    <div class="col-sm-2 m-b-xs">
                                        <input id="keyword" name="keyword" placeholder="orderId" class="form-control" type="text" />
                                    </div>
                                    <div class="col-sm-2 m-b-xs">
                                        <button class="btn btn-primary btn-block" type="submit"><i class="fa fa-search"></i>&nbsp;&nbsp;&nbsp;&nbsp;<strong>搜索</strong></button>
                                    </div>
                                </div>
                            </form>
                            <div class="row">
                                <div class="col-sm-6 m-b-xs">
                                 
                                </div>
                                <div class="col-sm-6 m-b-xs">
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-title">
                            <h5>订单列表</h5>
                            <div class="ibox-tools">
                                <a class="collapse-link">
                                    <i class="fa fa-chevron-up"></i>
                                </a>
                            </div>
                        </div>
                        <div class="ibox-content">
                            <div class="table-responsive">
                                <table class=" table table-hover" data-page-size="10">
                                    <thead>
                                    <tr>
                                        <th width="15%">Order ID</th>
                                        <th width="25%">Date</th>
                                        <th width="10%">Total Price</th>
                                        <th width="10%">Status</th>
                                        <th width="20%">Update</th>
                                        <th width="20%">Delete</th>
<!--                                        <th width="8%">买家昵称</th>-->
<!--                                        <td width="15%">订单创建时间</td>-->
<!--                                        <th>操作</th>-->
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr th:each="order:${session.allOrderList}">
                                        <td><a th:href="@{/manage/toShowOrder(orderId=${order.orderId})}" th:text="${order.orderId}">Onions</a></td>
                                        <td th:text="${#dates.format(order.orderDate, 'yyyy-MM-dd')}">Onions</td>
                                        <td th:text="'$'+${#numbers.formatDecimal(order.totalPrice,1,'COMMA',2,'POINT')}">Onions</td>
                                        <td>

                                            <!--a th:href="@{/manager/deliver(orderId=${order.orderId})}"  th:id="${order.orderId}" th:onclick="myFunction([[${order.orderId}]]);" th:value="${order.status}" th:text="${order.status}"></a>-->
                                            <a href="#" th:id="${order.orderId}"  th:name="${order.orderId}" th:value="${order.status}" th:onclick="Update([[${order.orderId}]]);" th:text="${order.status}"></a>
                                            <script type = "text/javascript">
                                                function Update(data) {
                                                    var status = document.getElementById(data).innerText;
                                                    console.log("start now " + status);
                                                    var r;
                                                    if(status == "delivered")
                                                    {r=confirm("Do you want to " + data + " to be not delivered?");}
                                                    else  {r=confirm("Do you want to " + data + " to be delivered?");}

                                                    console.log("start now " + data);

                                                    if(r == true){
                                                        $.ajax({
                                                            type  : "GET",
                                                            url   : "/manage/deliver?orderId="+data,
                                                            success : function () {
                                                                console.log("success to get into ajax");
                                                                if(status == "DELIVERED"){
                                                                    status = "NOT DELIVERED";
                                                                }
                                                                else {
                                                                    status = "DELIVERED";
                                                                }
                                                                location.reload();
                                                            }
                                                        });
                                                    }

                                                }

                                            </script>
                                        </td>
                                        <td><a th:href="@{/manage/updateOrder(orderId=${order.orderId})}" id="update" >update</a></td>
                                        <td><a th:href="@{/manage/removeOrder(orderId=${order.orderId})}" id="remove" >remove</a></td>
<!--                                        <td>Onions</td>-->
<!--                                        <td>Onions</td>-->
<!--                                        <td>-->
<!--                                            <a title="查看详情">查看详情</a>-->
<!--                                        </td>-->
                                    </tr>
                                    </tbody>
                                    <tfoot>
                                    <tr>
                                        <td colspan="9">
                                            <ul id="pageHTML" class="pagination pull-right"></ul>
                                        </td>
                                    </tr>
                                    </tfoot>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="footer" th:include="/manage/footer :: copyright"></div>
    </div>
</div>

<!-- Mainly scripts -->
<script th:src="@{../../js/jquery-2.1.1.js}"></script>
<script th:src="@{../../js/bootstrap.min.js}"></script>
<script th:src="@{../../js/plugins/metisMenu/jquery.metisMenu.js}"></script>
<script th:src="@{../../js/plugins/slimscroll/jquery.slimscroll.min.js}"></script>

<!-- Peity -->
<script th:src="@{../../js/plugins/peity/jquery.peity.min.js}"></script>

<!-- Custom and plugin javascript -->
<script th:src="@{../../js/inspinia.js}"></script>
<script th:src="@{../../js/plugins/pace/pace.min.js}"></script>

<!-- iCheck -->
<script th:src="@{../../js/plugins/iCheck/icheck.min.js}"></script>

<!-- Peity -->
<script th:src="@{../../js/demo/peity-demo.js}"></script>

<!-- FooTable -->
<script th:src="@{../../js/plugins/footable/footable.all.min.js}"></script>

<!-- common -->
<script th:src="@{../../js/common.js}"></script>


<!-- datepicker -->
<script th:src="@{../../js/bootstrap.js}"></script>
<script th:src="@{../../js/bootstrap.min.js}"></script>
<script th:src="@{../../js/bootstrap-datetimepicker.js}"></script>
<script th:src="@{../../js/locales/bootstrap-datetimepicker.zh-CN.js}"></script>



<script th:inline="javascript">
    $("#minOrderTimeStr").datetimepicker({
        format: "yyyy-mm-dd",
        autoclose: true,
        todayBtn: true,
        todayHighlight: true,
        showMeridian: true,
        pickerPosition: "bottom-left",
        language: 'zh-CN',//中文，需要引用zh-CN.js包
        startView: 2,//月视图
        minView: 2//日期时间选择器所能够提供的最精确的时间选择视图
    });

    $("#maxOrderTimeStr").datetimepicker({
        format: "yyyy-mm-dd",
        autoclose: true,
        todayBtn: true,
        todayHighlight: true,
        showMeridian: true,
        pickerPosition: "bottom-left",
        language: 'zh-CN',//中文，需要引用zh-CN.js包
        startView: 2,//月视图
        minView: 2//日期时间选择器所能够提供的最精确的时间选择视图
    });
</script>

</body>

</html>
